package com.yitao.cms.service.order;

import com.skipper.base.data.querydsl.PredicateBuilder;
import com.skipper.base.service.GenericEntityService;
import com.yitao.client.dto.order.UserOrderGradePreferentialDto;
import com.yitao.client.model.order.QUserOrderGradePreferentialModel;
import com.yitao.client.model.order.UserOrderGradePreferentialModel;
import org.springframework.stereotype.Service;

import javax.persistence.EntityManager;

/**
 * @Date: 2020/1/6 15:18
 * @Author: Kien
 */
@Service
public class CmsUserOrderGradePreferentialService extends GenericEntityService<UserOrderGradePreferentialModel, UserOrderGradePreferentialDto, QUserOrderGradePreferentialModel> {

    public CmsUserOrderGradePreferentialService(EntityManager entityManager) {
        super(entityManager);
    }

    /**
     * 功能描述: 根据订单id获取
     *
     * @param orderId 订单父id
     *
     * @return
     * @auther Kien
     * @date 2020/1/3 17:10
     */
    public UserOrderGradePreferentialModel findInfoByOrderId(Long orderId){
        if(orderId == null) {
            logger.info("订单id不能为空");
            return null;
        }
        return repository.findOne(PredicateBuilder.conjunction()
                .and(() -> Q.orderId.eq(orderId)).get());
    }
}
